﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace Boom.Navigation
{
    public class CheckKeyBoard:GameComponent
    {
        public KeyboardState OldKey;
        public KeyboardState NewKey;
        private TimeSpan _ElapsedTimeKey;

        public bool Left, Up, Right, Down, One, Two, Three, Four;
        public bool Space;
        public CheckKeyBoard(Game Mygame)
            : base(Mygame)
        {
            NewKey = Keyboard.GetState();
            _ElapsedTimeKey = TimeSpan.Zero;
        }

        private void CheckKey()
        {
            NewKey = Keyboard.GetState();
            //Dừng di chuyển
            Left = (OldKey.IsKeyDown(Keys.Left) && NewKey.IsKeyUp(Keys.Left));
            Up = (OldKey.IsKeyDown(Keys.Up) && NewKey.IsKeyUp(Keys.Up));
            Right = (OldKey.IsKeyDown(Keys.Right) && NewKey.IsKeyUp(Keys.Right));
            Down=(OldKey.IsKeyDown(Keys.Down) && NewKey.IsKeyUp(Keys.Down));

            //Đặt boom
            Space = (OldKey.IsKeyDown(Keys.Space) && NewKey.IsKeyUp(Keys.Space));

            //Items of Player
            One = (OldKey.IsKeyDown(Keys.NumPad1) && NewKey.IsKeyUp(Keys.NumPad1));
            Two = (OldKey.IsKeyDown(Keys.NumPad2) && NewKey.IsKeyUp(Keys.NumPad2));
            Three = (OldKey.IsKeyDown(Keys.NumPad3) && NewKey.IsKeyUp(Keys.NumPad3));
            Four = (OldKey.IsKeyDown(Keys.NumPad4) && NewKey.IsKeyUp(Keys.NumPad4));

            OldKey = NewKey;
        }

        public override void Update(GameTime gameTime)
        {
            CheckKey();
            base.Update(gameTime);  
        }
        
            



        
    }
}
